import { Component, OnInit } from '@angular/core';

// 导入storage服务
import { StorageService } from '../../service/storage.service';

// 导入路由服务
import { Router } from '@angular/router';

@Component({
  selector: 'app-tag-add',
  templateUrl: './tag-add.component.html',
  styleUrls: ['./tag-add.component.css']
})
export class TagAddComponent implements OnInit {

  private tagName:string='';

  constructor(
    private router:Router,
    private storage:StorageService
  ) { }

  ngOnInit() {
  }

  // 新增标签
  addHandle(f){
    if(this.tagName.trim()==''){
      alert('请填写标签名称');
    }else{
      this.storage.tagAdd({
        name:this.tagName
      });
      this.tagName='';
      this.router.navigate(['/taglist']);
    }
  }

}
